package com.yami.shop.common.config;

import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PropertiesLoaderUtils;

import java.io.IOException;
import java.util.Properties;

/**
 * AlipayAuth 参数读取
 * @author zy
 * @email for_office@qq.com
 * @time 2020-08-10 10:15:15
 */
@EnableCaching
@Configuration
public class AlipayAuthProperties {

    private static Properties alipayAuthProperties;

    public AlipayAuthProperties(){
        try {
            if (alipayAuthProperties == null) {
                alipayAuthProperties = PropertiesLoaderUtils.loadAllProperties("config/alipayAuth.properties");
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private String aliPublicKey;

    private String privateKey;

    private String aliPayUrl;

    private String appId;

    private String signType;

    private String aliPayBackUrl;

    private String quitUrl;

    private String returnUrl;

    private String payType;

    private String aPIv3;

    private String aliPayNative;

    public String getAliPayNative() {
        return alipayAuthProperties.getProperty("alipay.aliPayNative");
    }

    public String getaPIv3() {
         return alipayAuthProperties.getProperty("alipay.APIv3");
    }

    public String getAliPublicKey() {
        return alipayAuthProperties.getProperty("alipay.aliPublicKey");
    }

    public String getPrivateKey() {
        return alipayAuthProperties.getProperty("alipay.privateKey");
    }

    public String getAliPayUrl() {
        return alipayAuthProperties.getProperty("alipay.aliPayUrl");
    }

    public String getAppId() {
        return alipayAuthProperties.getProperty("alipay.appId");
    }

    public String getSignType() {
        return alipayAuthProperties.getProperty("alipay.signType");
    }

    public String getAliPayBackUrl() {
        return alipayAuthProperties.getProperty("alipay.aliPayBackUrl");
    }

    public String getQuitUrl() {
        return alipayAuthProperties.getProperty("alipay.quitUrl");
    }

    public String getReturnUrl() {
        return alipayAuthProperties.getProperty("alipay.returnUrl");
    }

    public String getPayType() {
        return alipayAuthProperties.getProperty("alipay.payType");
    }

    public Properties getAlipayAuthProperties() throws IOException {
        return  alipayAuthProperties;
    }
}
